﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebProjectOrder.BusinessLayer;
using WebProjectOrder.WebServices;
using System.Collections;

namespace WebProjectOrder.Presentation
{
    public partial class Authentication : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {

        }

        
        protected void login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            Hashtable newHash = AuthenticationManager.getInstance().GetAuxiliarAccountsList();
            foreach (AuxiliarAccount auxAccount in newHash.Values)
            {
                String username = login.UserName.ToString();
                String pass = login.Password.ToString();
                if (login.UserName.Equals(auxAccount.AccountCode) && login.Password.Equals(auxAccount.Contrasena))
                {
                    ConfigurationManager.GetInstance().AccountSelected = auxAccount;
                    e.Authenticated = true;
                    Response.Redirect("http://localhost:4501/Presentation/BuyOrder.aspx");

                }
                else { }
            }
                
         } 
    }
}